package com.ttt.adbgui.function;

import com.ttt.adbgui.jcomp.JFrameComponent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Objects;

@Component
@Slf4j
public class SetDevices {

    @Autowired
    private JFrameComponent jFrameComponent;

    public void setConnectDevices(){

        JPanel contentPane = jFrameComponent.getContentPane();
        ArrayList<String> resultStr = jFrameComponent.getResultStr();
        Object dialog = JOptionPane.showInputDialog(contentPane, "请选择用户名",
                "选择用户名",
                1, null,
                resultStr.toArray(),
                "");

        if (Objects.nonNull(dialog)){
            JLabel select = jFrameComponent.getJLabelSelect();
            select.setText(String.valueOf(dialog));
            jFrameComponent.setDeviceName(String.valueOf(dialog));
        }
    }
}
